package com.kancy.drools.demo.rulegroup;

import com.kancy.drools.demo.BaseTests;
import org.junit.Test;
import org.kie.api.runtime.KieContainer;
import org.kie.api.runtime.KieSession;
import org.kie.api.runtime.rule.AgendaGroup;

/**
 * @author kancy
 * @date 2020/1/19 0:20
 **/
public class RuleGroupTests extends BaseTests {
    @Test
    public void agendaGroupTest(){
        KieContainer kieContainer = getKieContainer();
        KieSession kieSession = kieContainer.newKieSession("rulegroup-session");
        AgendaGroup agendaGroup = kieSession.getAgenda().getAgendaGroup("agenda-group-dev");
        agendaGroup.setFocus();

        kieSession.fireAllRules();
        kieSession.dispose();
    }
    @Test
    public void agendaGroupAutoFocusTest(){
        KieContainer kieContainer = getKieContainer();
        KieSession kieSession = kieContainer.newKieSession("rulegroup-session");
        // 会执行自动聚焦的规则组
        kieSession.fireAllRules();
        kieSession.dispose();
    }

    @Test
    public void ruleflowGroupTest(){
        KieContainer kieContainer = getKieContainer();
        KieSession kieSession = kieContainer.newKieSession("rulegroup-session");
        kieSession.fireAllRules();
        kieSession.dispose();
    }

    @Test
    public void activationGroupTest(){
        KieContainer kieContainer = getKieContainer();
        KieSession kieSession = kieContainer.newKieSession("rulegroup-session");
        kieSession.fireAllRules();
        kieSession.dispose();
    }

}
